package pages

import (
	"github.com/templui/templui/internal/ui/layouts"
	"github.com/templui/templui/internal/ui/modules"
	"github.com/templui/templui/internal/ui/showcase"
)

templ Textarea() {
	@layouts.DocsLayout(
		"Textarea",
		"Multi-line text field for longer form content.",
		[]modules.TableOfContentsItem{
			{
				ID:   "installation",
				Text: "Installation",
			},
			{
				Text: "Examples",
				ID:   "examples",
				Children: []modules.TableOfContentsItem{
					{
						Text: "Custom Rows",
						ID:   "custom-rows",
					},
					{
						Text: "Auto Resize",
						ID:   "auto-resize",
					},
					{
						Text: "With Label",
						ID:   "with-label",
					},
					{
						Text: "Disabled",
						ID:   "disabled",
					},
					{
						Text: "Form",
						ID:   "form",
					},
				},
			},
			{
				ID:   "api",
				Text: "API Reference",
				Children: []modules.TableOfContentsItem{
					{
						ID:   "textarea",
						Text: "Textarea",
					},
				},
			},
		},
	) {
		@modules.PageWrapper(modules.PageWrapperProps{
			Name:        "Textarea",
			Description: templ.Raw("Multi-line text field for longer form content."),
			Tailwind:    true,
			VanillaJS:   true,
			Breadcrumbs: modules.Breadcrumbs{
				Items: []modules.BreadcrumbItem{
					{
						Text: "Docs",
						Path: "/docs",
					},
					{
						Text: "Components",
						Path: "/docs/components",
					},
					{
						Text: "Textarea",
					},
				},
			},
		}) {
			@modules.ExampleWrapper(modules.ExampleWrapperProps{
				ShowcaseFile:    showcase.TextareaDefault(),
				PreviewCodeFile: "textarea_default.templ",
			})
			@modules.ContainerWrapper(modules.ContainerWrapperProps{
				Title: "Installation",
				ID:    "installation",
			}) {
				@modules.ComponentUsage(modules.ComponentUsageProps{
					ComponentName: "textarea",
					JSFiles:       []string{"textarea"},
				})
			}
			@modules.ContainerWrapper(modules.ContainerWrapperProps{
				Title: "Examples",
				ID:    "examples",
			}) {
				@modules.ExampleWrapper(modules.ExampleWrapperProps{
					SectionName:     "Custom Rows",
					ShowcaseFile:    showcase.TextareaCustomRows(),
					PreviewCodeFile: "textarea_custom_rows.templ",
					ID:              "custom-rows",
				})
				@modules.ExampleWrapper(modules.ExampleWrapperProps{
					SectionName:     "Auto Resize",
					ShowcaseFile:    showcase.TextareaAutoResize(),
					PreviewCodeFile: "textarea_auto_resize.templ",
					ID:              "auto-resize",
				})
				@modules.ExampleWrapper(modules.ExampleWrapperProps{
					SectionName:     "With Label",
					ShowcaseFile:    showcase.TextareaWithLabel(),
					PreviewCodeFile: "textarea_with_label.templ",
					ID:              "with-label",
				})
				@modules.ExampleWrapper(modules.ExampleWrapperProps{
					SectionName:     "Disabled",
					ShowcaseFile:    showcase.TextareaDisabled(),
					PreviewCodeFile: "textarea_disabled.templ",
					ID:              "disabled",
				})
				@modules.ExampleWrapper(modules.ExampleWrapperProps{
					SectionName:     "Form",
					ShowcaseFile:    showcase.TextareaForm(),
					PreviewCodeFile: "textarea_form.templ",
					ID:              "form",
				})
			}
			@modules.ContainerWrapper(modules.ContainerWrapperProps{
				Title: "API Reference",
				ID:    "api",
			}) {
				@modules.APILegend()
				<div id="textarea" class="mb-8">
					@modules.APITable(modules.APITableProps{
						Title:       "Textarea",
						Description: "Multi-line text field component for longer form content with auto-resize capability.",
						Items: []modules.APITableItem{
							{
								Name:        "ID",
								Type:        "string",
								Default:     "",
								Description: "Unique identifier for the textarea element.",
								Required:    false,
							},
							{
								Name:        "Class",
								Type:        "string",
								Default:     "",
								Description: "Additional CSS classes to apply to the textarea.",
								Required:    false,
							},
							{
								Name:        "Attributes",
								Type:        "templ.Attributes",
								Default:     "",
								Description: "Additional HTML attributes to apply to the textarea element.",
								Required:    false,
							},
							{
								Name:        "Name",
								Type:        "string",
								Default:     "",
								Description: "Name attribute for form submission.",
								Required:    false,
							},
							{
								Name:        "Placeholder",
								Type:        "string",
								Default:     "",
								Description: "Placeholder text displayed when textarea is empty.",
								Required:    false,
							},
							{
								Name:        "Value",
								Type:        "string",
								Default:     "",
								Description: "Initial value of the textarea.",
								Required:    false,
							},
							{
								Name:        "Rows",
								Type:        "int",
								Default:     "3",
								Description: "Number of visible text lines in the textarea.",
								Required:    false,
							},
							{
								Name:        "Disabled",
								Type:        "bool",
								Default:     "false",
								Description: "Whether the textarea is disabled and non-interactive.",
								Required:    false,
							},
							{
								Name:        "AutoResize",
								Type:        "bool",
								Default:     "false",
								Description: "Whether the textarea should automatically resize based on content.",
								Required:    false,
							},
							{
								Name:        "ReadOnly",
								Type:        "bool",
								Default:     "false",
								Description: "Whether the textarea is read-only.",
								Required:    false,
							},
						},
					})
				</div>
			}
		}
	}
}
